<layout name="layout" />
<link href="__PUBLIC__/Home/css/bootstrap.css" rel="stylesheet" />
<link href="__PUBLIC__/Common/html/assets/plugins/jquery/jquery-1.9.1.min.js" rel="stylesheet" />
<link href="__PUBLIC__/Common/html/assets/plugins/bootstrap/js/bootstrap.min.js" rel="stylesheet" />
<script type="text/javascript" src="__PUBLIC__/Admin/js/layer.js"></script>
<!-- 搜索 -->
<div class="form-div search_form_div">
    <form action="__ACTION__" method="GET" name="search_form">
		<p>
			名称：
	   		<input type="text" name="name" size="30" value="<?php echo I('get.name'); ?>" />
		</p>
		<p>
			类别：
	   		<input type="text" name="card_type" size="30" value="<?php echo I('get.card_type'); ?>" />
		</p>
		<p><input type="submit" value=" 搜索 " class="button" /></p>
    </form>
</div>
<!-- 列表 -->
<div class="list-div" id="listDiv">
	<table cellpadding="3" cellspacing="1">
    	<tr>
            <th >编码</th>
            <th >名称</th>
            <th >价格</th>
            <th >最低价格</th>
            <th >有效期</th>
            <th >有效次数</th>
            <th >储值</th>
            <th >折扣</th>
            <th >积分</th>
            <th >介绍人积分</th>
            <th >类别</th>
            <th >备注</th>
            <th >状态</th>
            <th >会员卡数</th>
            <th >是否显示</th>
            <th >排序</th>
            <th >对外名称</th>
			<th style="width: 500px">操作</th>
        </tr>
		<?php foreach ($data as $k => $v): ?>            
			<tr class="tron">
				<td  height="60"><?php echo $v['code']; ?></td>
				<td><?php echo $v['name']; ?></td>
				<td><?php echo $v['price']; ?></td>
				<td><?php echo $v['low_price']; ?></td>
				<td><?php echo $v['effective_day']; ?></td>
				<td><?php echo $v['effective_frequency']; ?></td>
				<td><?php echo $v['effective_money']; ?></td>
				<td><?php echo $v['discount']; ?></td>
				<td><?php echo $v['integral']; ?></td>
				<td><?php echo $v['intro_integral']; ?></td>
				<td><?php getIdByName('card_type',$v['card_type'],'name'); ?></td>
				<td><?php echo $v['comment']; ?></td>
				<td><?php echo $v['status']; ?></td>
				<td><?php echo $v['member_id']; ?></td>
				<td><?php echo $v['is_show']; ?></td>
				<td><?php echo $v['sort']; ?></td>
				<td><?php echo $v['alias']; ?></td>
		        <td align="center">
		        	<a href="<?php echo U('edit?id='.$v['id'].'&p='.I('get.p')); ?>" title="编辑">编辑</a> |
	                <a href="<?php echo U('delete?id='.$v['id'].'&p='.I('get.p')); ?>" onclick="return confirm('确定要删除吗？');" title="移除">移除</a>
					<a class="btn button-info" href="JavaScript:void(0);"  onclick="courseRule({:$v['id']});" title="">规则</a> |
					<a class="btn button-info" href="JavaScript:void(0);" onclick="courseLimit({:$v['id']})" title="课程限制">课程限制</a> |
					<a class="btn button-info" href="JavaScript:void(0);"  onclick="courseCate({:$v['id']});" title="">分类限制</a> |
				</td>
	        </tr>
        <?php endforeach; ?> 
		<?php if(preg_match('/\d/', $page)): ?>  
        <tr><td align="right" nowrap="true" colspan="99" height="30"><?php echo $page; ?></td></tr> 
        <?php endif; ?> 
	</table>
	<div class="modal in" id="setRulesDiv" aria-hidden="false" style="display: none;">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<h4 class="modal-title">设置使用规则</h4>
				</div>
				<div class="modal-body">
					<div class="well" id="wellone">


					</div>
					<div class="panel-primary">

						<div class="panel-heading">
							<span class="panel-title" style="font-size:1em">设定新规则&nbsp;&nbsp;注意！设定新规则会删除老规则</span>
						</div>
						<div class="panel-body" style="padding:1em">
							<form action="{:U('setcardguize')}"  id="rule_submit_form" class="form-horizontal" method="post" accept-charset="utf-8">
								<input name="cardTypeId" type="hidden" id="cardTypeId" value="">

								<div class="row" id="canCross">
									<div class="col-lg-1">
										<input type="checkbox" name="ruleCheckBox[]" value="canCross">
									</div>
									<div class="col-lg-3">跨门店限制</div>
									<div class="col-lg-8">该卡是否可以跨门店使用
										<select name="canCross">
										<option value="YES">是</option><option value="NO">否</option>
										</select>
									</div>
								</div>
								<br>

								<div class="row" id="dateOddEven">
									<div class="col-lg-1">
										<input type="checkbox" name="ruleCheckBox[]" value="dateOddEven">
									</div>
									<div class="col-lg-3">单双日限制</div>
									<div class="col-lg-8">该卡仅限<select name="dateOddEven"><option value="odd">单</option><option value="even">双</option></select>日</div>
								</div>
								<br>

								<div class="row" id="timeZone">
									<div class="col-lg-1">
										<input type="checkbox" name="ruleCheckBox[]" value="timeZone">
									</div>
									<div class="col-lg-3">时间范围限制</div>
									<div class="col-lg-8">该卡仅限<input name="timeZoneBeginTime" id="timeZoneBeginTime"  style="width:6em">至<input name="timeZoneEndTime" id="timeZoneEndTime" style="width:6em"></div>
								</div>
								<br>

								<div class="row" id="weekDay">
									<div class="col-lg-1">
										<input type="checkbox" name="ruleCheckBox[]" value="weekDay">
									</div>
									<div class="col-lg-3">一周日期限制</div>
									<div class="col-lg-8">该卡仅限周
										<input type="checkbox" name="weekDay[1]" value="1">一						<input type="checkbox" name="weekDay[2]" value="2">二						<input type="checkbox" name="weekDay[3]" value="3">三						<input type="checkbox" name="weekDay[4]" value="4">四						<input type="checkbox" name="weekDay[5]" value="5">五						<input type="checkbox" name="weekDay[6]" value="6">六						<input type="checkbox" name="weekDay[7]" value="7">日						</div>
								</div>
								<br>

								<div class="row" id="weekTimes">
									<div class="col-lg-1">
										<input type="checkbox" name="ruleCheckBox[]" value="weekTimes">
									</div>
									<div class="col-lg-3">一周多次限制</div>
									<div class="col-lg-8">每周最多上课/预约<input name="weekTimes" style="width:3em">次</div>
								</div>
								<br>

								<div class="row" id="dayTimes">
									<div class="col-lg-1">
										<input type="checkbox" name="ruleCheckBox[]" value="dayTimes">
									</div>
									<div class="col-lg-3">一天多次限制</div>
									<div class="col-lg-8">每天最多上课/预约<input name="dayTimes" style="width:3em">次</div>
								</div>
							</form></div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" id="ruleCancel" class="btn btn-default btn-sm" data-dismiss="modal">取消</button>
					<button type="submit" id="rule_submit" onclick="$('#rule_submit_form').submit()" class="btn btn-primary btn-sm">确定</button>
				</div>
			</div>
		</div>
	</div></div>
    <div class="modal in" id="classTypeModal" aria-hidden="false" style="display: none;">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
				<h4 class="modal-title">课程分类限制</h4>
			</div>
			<div class="modal-body" id="classTypeBody"><form action="" class="form-horizontal" method="post" accept-charset="utf-8"><input type="hidden" name="cardTypeId" value="11637">
				<table class="table table-bordered ">
					<tbody><tr class="success">
						<th>分类名称</th>
						<th>分类次数</th>
					</tr>
					</tbody></table>
				<br>
				<button type="submit" id="cateCancel" class="btn btn-success">保存</button>
			</form></div>
		</div>
	</div>
</div>
    <!--修改卡项层-->
    <div class="modal" id="cardtypecourseDiv" style="display: none;">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true" name="closecardtypecourseDiv">×</button>
				<h4 class="modal-title">限制课程设定</h4>
			</div>
			<div class="modal-body">
				<h5>不能预约和上课的课程</h5>
				<div class="well">


				</div>
				<h5>请选择不允许预约和上课的课程&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:red;font-size:10px"> 注：新选项会覆盖原选项</span></h5>
				<form action="{:U('setnoclass')}" method="post"  id="cardsetnoclass" accept-charset="utf-8">
					<input type="hidden" name="cardtypeid" value="11637">
					<div id="getjsoninfo">

					</div>


				</form></div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default btn-sm" data-dismiss="modal" id="cancelLimit" name="closecardtypecourseDiv">关闭</button>
				<button type="button" onclick="$('#cardsetnoclass').submit()" class="btn btn-primary btn-sm">保存</button>
			</div>
		</div>
	</div>
</div>
<script src="__PUBLIC__/Admin/Js/tron.js"></script>
<link href="__PUBLIC__/jedate/skin/jedate.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/jedate/jquery.jedate.js"></script>

<script type="text/javascript">

	//规则
    $.jeDate("#timeZoneBeginTime",{
        format:"hh:mm"
    });
    $.jeDate("#timeZoneEndTime",{
        format:"hh:mm"
    });
    $(document).ready(function () {
        $(".close").click(function () {
            $(this).parent("div").parent("div").parent("div").parent("div").hide();
        })



    });
    function courseRule(id){

        $("input[name='cardTypeId']").val("");
        $("input[name='cardTypeId']").val(id);
        $("#setRulesDiv").show();

        $.post("{:U('setguize')}", { id: id },
            function(data){
				$("#wellone").html(data);
            }, "json");
     }
    $('#ruleCancel').click(function () {
        $("#setRulesDiv").hide();
    });
    $("#rule_submit").click(function () {

    });
    //课程分类
    function courseCate(id){
        $("#classTypeModal").show();
    }
    $('#cateCancel').click(function () {
        $("#classTypeModal").hide();
    });

    //课程限制
     function courseLimit(id){
         $("input[name='cardtypeid']").val("");
         $("input[name='cardtypeid']").val(id);
         var h = "",m="";
        $("#cardtypecourseDiv").show();
         $.post("{:U('getnoclass')}", { id: id },
             function(data){
             	var aclass = data.all , nclass=data.noclass;

                 for(var a=0;a<nclass.length;a++)
                 {
                     m +='<span><i class="icon-check"></i>'+nclass[a].course_name+'</span> &nbsp;&nbsp;&nbsp;';
                 }
				$(".well").html(m);
				for(var i=0;i<aclass.length;i++)
				{
					h +='<div style="width:33%; display:inline-block"><input type="checkbox" name="cardtypecourseCheck[]" value="'+aclass[i].id+'"><span>'+aclass[i].course_name+'</span></div>';
				}

				$("#getjsoninfo").html(h);
             }, "json");
     }


      $('#cancelLimit').click(function () {
            $("#cardtypecourseDiv").hide();
        });



</script>